package com.lyn.chapter3.demo2;

/**
 * 多线程可用，但存在性能问题，因为每次获取单例时都要创建锁
 * @author mac
 *
 */
public class SimpleMultithreadedSingleton {
	private static SimpleMultithreadedSingleton instance = null;
	private SimpleMultithreadedSingleton() {
		//什么也不做
	}
	 public static SimpleMultithreadedSingleton getInstance() {
		 synchronized (SimpleMultithreadedSingleton.class) {
			if(null == instance) {
				instance = new SimpleMultithreadedSingleton();
			}
		}
		 return instance;
	 }
	 
	 public void someService() {
		 //省略其他代码
	 }
}
